博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
用windows live writer写的
阅读量:6690 次
发布时间:2019-06-25

本文共 5698 字,大约阅读时间需要 18 分钟。

关于配置

发布配置

http://你的blog地址/metawebblog.axd

 

#region Usingusing System;using System.Web;using System.Collections.Generic;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.HtmlControls;using BlogEngine.Core;#endregionpublic partial class archive : BlogEngine.Core.Web.Controls.BlogBasePage{    ///     /// Handles the Load event of the Page control.    ///     /// The source of the event.    /// The 
instance containing the event data. protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack && !IsCallback) { CreateMenu(); CreateArchive(); AddTotals(); } Page.Title = Server.HtmlEncode(Resources.labels.archive); base.AddMetaTag("description", Resources.labels.archive + " | " + BlogSettings.Instance.Name); } /// /// Creates the category top menu. /// private void CreateMenu() { foreach (Category cat in Category.Categories) { AddCategoryToMenu(cat.Title); } } private void AddCategoryToMenu(string title) { HtmlAnchor a = new HtmlAnchor(); a.InnerHtml = Server.HtmlEncode(title); a.HRef = "#" + Utils.RemoveIllegalCharacters(title); a.Attributes.Add("rel", "directory"); HtmlGenericControl li = new HtmlGenericControl("li"); li.Controls.Add(a); ulMenu.Controls.Add(li); } /// /// Sorts the categories. /// /// The categories. private SortedDictionary
SortCategories(Dictionary
categories) { SortedDictionary
dic = new SortedDictionary
(); foreach (Category cat in Category.Categories) { dic.Add(cat.Title, cat.Id); } return dic; } private void CreateArchive() { foreach (Category cat in Category.Categories) { string name = cat.Title; List
list = Post.GetPostsByCategory(cat.Id).FindAll(delegate(Post p) { return p.IsVisible; }); HtmlGenericControl h2 = CreateRowHeader(cat.Id, name, list.Count); phArchive.Controls.Add(h2); HtmlTable table = CreateTable(name); foreach (Post post in list) { CreateTableRow(table, post); } phArchive.Controls.Add(table); } List
noCatList = Post.Posts.FindAll(delegate(Post p) { return p.Categories.Count == 0; }); if (noCatList.Count > 0) { string name = Resources.labels.uncategorized; HtmlGenericControl h2 = CreateRowHeader(Guid.NewGuid(), name, noCatList.Count); phArchive.Controls.Add(h2); HtmlTable table = CreateTable(name); foreach (Post post in noCatList) { CreateTableRow(table, post); } phArchive.Controls.Add(table); AddCategoryToMenu(name); } } private static HtmlGenericControl CreateRowHeader(Guid id, string name, int count) { HtmlAnchor feed = new HtmlAnchor(); feed.HRef = Utils.RelativeWebRoot + "category/syndication.axd?category=" + id.ToString(); HtmlImage img = new HtmlImage(); img.Src = Utils.RelativeWebRoot + "pics/rssbutton.gif"; img.Alt = "RSS"; feed.Controls.Add(img); HtmlGenericControl h2 = new HtmlGenericControl("h2"); h2.Attributes["id"] = Utils.RemoveIllegalCharacters(name); h2.Controls.Add(feed); Control header = new LiteralControl(name + " (" + count + ")"); h2.Controls.Add(header); return h2; } private static void CreateTableRow(HtmlTable table, Post post) { HtmlTableRow row = new HtmlTableRow(); HtmlTableCell date = new HtmlTableCell(); date.InnerHtml = post.DateCreated.ToString("yyyy-MM-dd"); date.Attributes.Add("class", "date"); row.Cells.Add(date); HtmlTableCell title = new HtmlTableCell(); title.InnerHtml = string.Format("
{1}", post.RelativeLink, post.Title); title.Attributes.Add("class", "title"); row.Cells.Add(title); if (BlogSettings.Instance.IsCommentsEnabled) { HtmlTableCell comments = new HtmlTableCell(); comments.InnerHtml = post.ApprovedComments.Count.ToString(); comments.Attributes.Add("class", "comments"); row.Cells.Add(comments); } if (BlogSettings.Instance.EnableRating) { HtmlTableCell rating = new HtmlTableCell(); rating.InnerHtml = post.Raters == 0 ? "None" : Math.Round(post.Rating, 1).ToString(); rating.Attributes.Add("class", "rating"); row.Cells.Add(rating); } table.Rows.Add(row); } private HtmlTable CreateTable(string name) { HtmlTable table = new HtmlTable(); table.Attributes.Add("summary", name); HtmlTableRow header = new HtmlTableRow(); HtmlTableCell date = new HtmlTableCell("th"); date.InnerHtml = base.Translate("date"); header.Cells.Add(date); HtmlTableCell title = new HtmlTableCell("th"); title.InnerHtml = base.Translate("title"); header.Cells.Add(title); if (BlogSettings.Instance.IsCommentsEnabled) { HtmlTableCell comments = new HtmlTableCell("th"); comments.InnerHtml = base.Translate("comments"); comments.Attributes.Add("class", "comments"); header.Cells.Add(comments); } if (BlogSettings.Instance.EnableRating) { HtmlTableCell rating = new HtmlTableCell("th"); rating.InnerHtml = base.Translate("rating"); rating.Attributes.Add("class", "rating"); header.Cells.Add(rating); } table.Rows.Add(header); return table; } private void AddTotals() { int comments = 0; int raters = 0; foreach (Post post in Post.Posts) { comments += post.ApprovedComments.Count; raters += post.Raters; } ltPosts.Text = Post.Posts.Count + " " + Resources.labels.posts.ToLowerInvariant(); if (BlogSettings.Instance.IsCommentsEnabled) ltComments.Text = comments + " " + Resources.labels.comments.ToLowerInvariant(); if (BlogSettings.Instance.EnableRating) ltRaters.Text = raters + " " + Resources.labels.raters.ToLowerInvariant(); }}
转载请注明出处[ ] 
作者赞赏
 
刚做的招标网:  请大家多意见
本文转自Sam Lin博客博客园博客,原文链接:http://www.cnblogs.com/samlin/archive/2009/07/29/1533980.html,如需转载请自行联系原作者
你可能感兴趣的文章
JQuery实现简单的服务器轮询效果
查看>>
幽灵漏洞(GHOST)影响大量Linux操作系统及其发行版(更新修复方案)
查看>>
Sunday算法
查看>>
windows下xcopy命令
查看>>
netstat
查看>>
优朋普乐:OTT正重构电视版图
查看>>
遇到"process launch failed: Security"问题,解决的一种方法
查看>>
Ubuntu 14.04 LTC 有线网络——网线不识别,灯不亮问题
查看>>
Unity3D DLL加密
查看>>
ubuntu root用户的密码
查看>>
linux ssh配置与禁用root远程登录
查看>>
Ngios plugin for cacti(NPC)
查看>>
求数组中最长递增子序列
查看>>
前端开发面试题(收集贴)
查看>>
Spring Boot cache backed redis
查看>>
有趣的编程----控制自己电脑的CPU
查看>>
linux的目录结构
查看>>
Java中创建对象的5种不同方法
查看>>
Supervisor安装
查看>>
自建框架知识点一命名空间和自动加载
查看>>